{% extends "base.html" %}

{% set active_page = "Database" %}



{% block head %}
	{# jstree import #}
    <script src="{{ url_for('static', filename='jstree/dist/jstree.min.js') }}"></script>
    <link rel="stylesheet" href="{{ url_for('static', filename='jstree/dist/themes/default/style.min.css') }}" />
{% endblock %}


{% block body %}

<table class="table table-bordered">
	<thead>
		<tr>
			<th class="active"></th>
			{% for uid in uid_list %}
				<th class="active">{{ result['general']['hid'][uid] }}</th>
			{% endfor %}
		</tr>
	</thead>
	<tbody>
	
	{# --- general information --- #}
		<tr>
			<th colspan="{{ uid_list | length + 1 }}" class="success" style="text-align:center;">General Information</th>
		</tr>
		{% for feature in result['general'] | sort %}
		<tr>
			<td class="active" width="150px"> {{ feature | replace_underscore }} </td>
			{% for uid in uid_list %}
				<td>
				{% if feature == "size"%}
					{{ result['general'][feature][uid] | number_format }}
				{% else %}
					{{ result['general'][feature][uid] | nice_list | replace_uid_with_hid | safe }}
				{% endif %}
				</td>
			{% endfor %}
		</tr>
		{% endfor %}
		
		{# --- plugin results --- #}
		
		{% for plugin in result['plugins'] | sort %}
		<tr>
			<th colspan="{{ uid_list | length  + 1 }}" class="success" style="text-align:center;">{{ plugin | replace_underscore }}</th>
		</tr>
            {% if plugin in plugins_without_view %}

                {# plugins without separate view #}
                {% for feature in result['plugins'][plugin] | sort %}
                    <tr>
                        <td class="active"> {{ feature | replace_underscore }} </td>

                        {# --- all case --- #}
                        {% if 'all' in result['plugins'][plugin][feature] %}
                            {% if result['plugins'][plugin][feature]['collapse'] %}
                                <td colspan="{{ uid_list | length }}">
                                    <center>
                                        <button type="button" class="btn btn-sm btn-fact-one" data-toggle="collapse" data-target="#{{ feature }}">
                                            {{ result['plugins'][plugin][feature]['all'] | length }}
                                        </button>
                                    </center>
                                    <div id="{{ feature }}" class="collapse">
                                        {{ result['plugins'][plugin][feature]['all'] | nice_list | uids_to_link | replace_uid_with_file_name | safe  }}
                                    </div>
                                </td>
                            {% else %}
                                <td colspan="{{ uid_list | length }}" style="text-align:center;"> {{ result['plugins'][plugin][feature]['all'] | nice_uid_list | safe }} </td>
                            {% endif %}

                        {# --- individual results --- #}
                        {% else %}
                            {% for uid in uid_list %}
                                <td>
                                {% if result['plugins'][plugin][feature]['collapse'] %}
                                    <center>
                                        <button type="button" class="btn btn-sm btn-primary" data-toggle="collapse" data-target="#{{ feature + uid }}">
                                            {{ result['plugins'][plugin][feature][uid] | length }}
                                        </button>
                                    </center>
                                    <div id="{{ feature + uid }}" class="collapse">
                                        {{ result['plugins'][plugin][feature][uid] | nice_list | uids_to_link(root_uid=uid) | replace_uid_with_file_name | safe }}
                                    </div>
                                {% else %}
                                    {{ result['plugins'][plugin][feature][uid] | nice_uid_list(root_uid=uid) | safe }}
                                {% endif %}
                                </td>
                            {% endfor %}
                        {% endif %}
                    </tr>
                {% endfor %}


            {# individual plugin views #}

            {% endif %}
		{% endfor %}
		
	</tbody>
</table>


{% endblock %}